function attachEventListener(target, eventType, functionRef, capture) {
	if (target) {
		if (typeof target.addEventListener != 'undefined') {
			target.addEventListener(eventType, functionRef, capture);
		} else if (typeof target.attachEvent != 'undefined') {
			target.attachEvent("on" + eventType, functionRef);
		} else {
			eventType = "on" + eventType;
			if (typeof target[eventType] == "function") {
				var oldListener = target[eventType];
				target[eventType] = function() {
					oldListener();
					return functionRef();
				};
			} else {
				target[eventType] = functionRef;
			}
		}
	}
}


function createNamedElement(type, name) {
   var element = null;
   // Try the IE way; this fails on standards-compliant browsers
   try {
      element = document.createElement('<'+type+' name="'+name+'">');
   } catch (e) {
   }
   if (!element || element.nodeName != type.toUpperCase()) {
      // Non-IE browser; use canonical method to create named element
      element = document.createElement(type);
      element.name = name;
   }
   return element;
}
